package com.hzsai.mininote.converter;

import com.hzsai.mininote.entity.NoteStateEnum;

import javax.persistence.AttributeConverter;

/**
 * @author hzsai
 * @date 2020/1/8 19:51
 * @usage:
 */
public class NoteStateEnumConverter implements AttributeConverter<NoteStateEnum, Integer> {
    @Override
    public Integer convertToDatabaseColumn(NoteStateEnum noteStateEnum) {
        return noteStateEnum.getId();
    }

    @Override
    public NoteStateEnum convertToEntityAttribute(Integer integer) {
        return NoteStateEnum.getNoteEnumFromId(integer);
    }
}
